package com.myworld.vo.response;

/**
 * 将返回给客户端的数据封装到实体类中
 */
public class Result implements ResultCode{
    private boolean success; // 是否操作成功
    private Integer code; //返回状态码
    private String message; // 返回消息
    private Object result; // 返回附件的对象

    /**
     * 通过 resultCode 构造 Result
     * @param resultCode
     */
    public Result(ResultCode resultCode){
        this.success=resultCode.success();
        this.code=resultCode.code();
        this.message=resultCode.message();
    }

    public Result(boolean success, String message) {
        this.success = success;
        this.message = message;
    }

    public Result(boolean success, String message, Object result) {
        this.success = success;
        this.message = message;
        this.result = result;
    }

    public Result(CommonCode commonCode,Object result){
        this.success=commonCode.success;
        this.code=commonCode.code;
        this.message=commonCode.message;
        this.result=result;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getResult() {
        return result;
    }

    public void setResult(Object result) {
        this.result = result;
    }

    @Override
    public boolean success() {
        return this.success;
    }

    @Override
    public int code() {
        return this.code;
    }

    @Override
    public String message() {
        return this.message;
    }
}
